#include <iostream>

struct debts
{
    char name[50];
    double amount;
};

template <class Type>               // template A
void ShowArray(Type arr[], int n)
{
    using namespace std;
    cout << "template A" << endl;
    for (int i = 0; i < n; i++)
    {
        cout << arr[i] << " ";
    }
    cout << endl;
}

#if 1
template <class Type>
void ShowArray(Type * arr[], int n) // template B
{
    using namespace std;
    cout << "template B" << endl;
    for (int i = 0; i < n; i++)
    {
        cout << *arr[i] << " ";
    }
    cout << endl;
}
#endif

void DoTemplateOverloading()
{
    using namespace std;
    int things[6] = {13, 31, 103, 301, 310, 130};
    struct debts mr_E[3] = {
        {"Ima Wolfe", 2400.0},
        {"Ura Foxe", 1300.0},
        {"Iby Stout", 1800.0}
    };
    double * pd[3];
    // set pointers to the amount members of the structures in mr_E
    for (int i = 0; i < 3; i++)
    {
        pd[i] = &mr_E[i].amount;
    }
    
    cout << "Listing Mr. E's counts of things:\n";
    // things is an array of int
    ShowArray(things, 6);       // uses template A

    cout << "Listing Mr. E's debts:\n";
    // pd is an array of pointers to double
    ShowArray(pd, 3);           // uses template B (most specialized)
}

int main(int argc, char const *argv[])
{
    DoTemplateOverloading();
    return 0;
}
